package com.zbxx.practice.designpattern.proxy.dynamicproxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * jdk 动态代理 只能代理实现了 某个接口的类
 *
 * @author 万仁杰
 * @date 2019/05/31
 */
public class JdkProxyInvocationHandler implements InvocationHandler {

    private Object proxyObject;

    public JdkProxyInvocationHandler(Object proxyObject){
        this.proxyObject = proxyObject;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("jdk dynamic proxy start");
        Object returnVal =  method.invoke(proxyObject,args);
        System.out.println("jdk dynamic proxy start");
        return returnVal;
    }
}
